/*
*
* ████████╗░█████╗░███████╗██████╗░░█████╗░
* ╚══██╔══╝██╔══██╗██╔════╝██╔══██╗██╔══██╗
* ░░░██║░░░██║░░██║█████╗░░██████╦╝███████║
* ░░░██║░░░██║░░██║██╔══╝░░██╔══██╗██╔══██║
* ░░░██║░░░╚█████╔╝██║░░░░░██████╦╝██║░░██║
* ░░░╚═╝░░░░╚════╝░╚═╝░░░░░╚═════╝░╚═╝░░╚═╝
* 
*  :: 九方通逊-Henry ::   Copyright©2020 tofba.com  
* 
*/
package com.lmexpress.util;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * <资源文件>
 * 
 * @author Henry(fba02)
 * @version [版本号, 2020-10-19]
 * @see [相关类/方法]
 * @since [产品/模块版本]
 */
public class PropertiesUtil {
    private static Logger LOGGER = LoggerFactory.getLogger(PropertiesUtil.class);    
    private static Properties properties;
    
    static {
        String fileName = "com/tofba/message.properties";
        properties = new Properties();
        try {
            String path = PropertiesUtil.class.getClassLoader().getResource("").getPath() + fileName;
            properties.load(new FileInputStream(path));
        } catch (IOException e) {
            LOGGER.error("message.properties.exception", e);
        }
    }
    
    public static String getProperty(String key) {
        String value = properties.getProperty(key.trim());
        if (StringUtils.isBlank(value)) {
            return null;
        }
        return value.trim();
    }
    
    public static String getProperty(String key, String defaultValue) {
        String value = properties.getProperty(key.trim());
        if (StringUtils.isBlank(value)) {
            value = defaultValue;
        }
        return value.trim();
    }
    
    public static void main(String[] args) {
        System.out.println(getProperty("system.remark"));
    }
}